

var React = require("react");


var {
  AppRegistry,
  StyleSheet,
  Text,
  View
} = require("react-native");


 var Son =  React.createClass({
    getDefaultProps:function(){
      console.log('getDefaultProps','儿子')
    },
    getInitialState: function () {
        console.log('getInitialState','儿子')
         return {
             times: this.props.times
         };
     },
    timePlus(){
        let times =this.state.times
        times++
      this.setState({
        times:times
      })
   },
   timeReset:function(){
     this.props.timeReset()
   },
  componentWillMount(){
    console.log('ComponentWillMont','子组件即将被安装')
  },
  render() {
      console.log('render','子组件渲染')
    return (
      <View style={styles.container}>
        <Text onPress= {this.timePlus} style={styles.welcome}>
         儿子：有本事揍我啊
        </Text>
        <Text style={styles.instructions}>
           你居然揍我 {this.state.times}次
        </Text>
        <Text onPress= {this.timeReset} style={styles.instructions}>
           信不信我亲亲你
        </Text>
      </View>
    );
  },
  componentDidMount(){
      console.log('ComponentWillMont','子组件即将被安装完毕')
  },
  componentWillReceiveProps(props){
    this.setState({
      times:props.times
    })
    console.log(this.props,props)
    console.log('componentWillReceiveProps','子组件属性对比')

  },
  shouldComponentUpdate(){
    console.log('shouldComponentWillUpdate','子要不要更新')
    return true
  },
  componentWillUpdate(){
      console.log('ComponentWillMont','子组件即将被更新完毕')
  },

  componentDidUpdate(){
        console.log('componentDidUpdate','子组件即将被更新完毕')
    },
  })
  var styles = StyleSheet.create({
    container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F5FCFF',
    },
    welcome: {
      fontSize: 20,
      textAlign: 'center',
      margin: 10,
    },
    instructions: {
      textAlign: 'center',
      color: '#333333',
      marginBottom: 5,
    },
  });
export default Son
module.exports =  Son;
